package com.yzr.topic;

import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.yzr.util.RabbitMqClient;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * 发布订阅-动态路由 topic
 */
public class Producer {
    public static void main(String[] args) throws IOException, TimeoutException {
        Connection connection = RabbitMqClient.getConnection();
        Channel channel = connection.createChannel();

        channel.exchangeDeclare("logs_topic", BuiltinExchangeType.TOPIC);

        channel.basicPublish("logs_topic", "logs.user", null, "hello topic".getBytes());

        RabbitMqClient.close(channel, connection);
    }
}
